package com.example.cuibo.basicarray;

import com.example.cuibo.basicarray.cn.itcast.list.Teacher;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

/**
 * Created by cuibo on 2017/10/31.
 */
@SuppressWarnings({"rawtypes","unchecked"})
public class Demo_List {

    public void xxx(){
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");

        list.add(1,"z");
        List list1 = new ArrayList();
        list1.add(new Student("1",12));
        list1.add(new Student("12",12));
        list1.add(new Student("14",12));
        list1.add(new Student("16",12));

        for (int i = 0; i < list1.size(); i++) { // 防止并发对同一个对象进行修改，
            Student s = (Student)list.get(i);
        }
        ListIterator lit = list.listIterator();
        while (lit.hasNext()){
            String str = (String)lit.next();
            if (str.equals("word")){
                lit.add("age");
            };

        }
        ArrayList listDemo = new ArrayList();
        listDemo.add(new Teacher("11",12));
        listDemo.add(new Teacher("15",12));
        listDemo.add(new Teacher("12",12));
        listDemo.add(new Teacher("13",12));

        ListIterator rator = list.listIterator();
        while (rator.hasNext()){
            Teacher t = (Teacher)lit.next();

        }
    }
}
